package at.jaki.ubb.crawling.api;

import java.util.List;

import at.jaki.ubb.crawling.model.CEEntity;
import at.jaki.ubb.crawling.model.DataTransformerResult;
import at.jaki.ubb.crawling.model.RawData;
import at.jaki.ubb.crawling.model.Target;

/**
 * Every DataTransformer used by the Crawling Engine has to implement this
 * interface. The engine controls the data transformer via the methods specified
 * here.
 * 
 * @author Attila Jakabfi
 * 
 * @param <T> generic type of result {@link Target}
 * @param <DR> generic type of result {@link RawData}
 * @param <E> generic type of result Entity
 * @param <DO> generic type of parameter {@link RawData}
 */
public interface DataTransformer<T, DR, E  extends CEEntity, DO> {

	/**
	 * This method will be called every time, when a task need to be completed
	 * by this data transformer. All the business logic must be implemented
	 * here.
	 * 
	 * @param rawData the input parameter of the data transformer
	 * @return The results.
	 */
	DataTransformerResult<T, DR, E> transformData(RawData<DO> rawData);

	/**
	 * This method will be called by the engine at startup. Used to set up user
	 * defined parameters, and perform startup actions.
	 */
	void init();

	/**
	 * This method tells the crawling engine what raw data types can be
	 * transformer by this data transformer. Only raw data with the type
	 * specified here, will be sent to this data finder.
	 * 
	 * @return A list of raw data types. Can't be null.
	 */
	List<String> getTypes();

}
